#!/bin/bash
# backup sysctl
sysctl -a > /var/log/sysctl.bak.$(date +%s)

# change sysctl
   sysctl -w  net.ipv4.tcp_keepalive_time=30;
   sysctl -w  net.ipv4.tcp_keepalive_probes=3;
   sysctl -w  net.ipv4.tcp_keepalive_intvl=5;
   sysctl -w  net.ipv4.tcp_fin_timeout=10;
   sysctl -w  net.ipv4.tcp_retries2=5;
   sysctl -w  net.ipv4.tcp_syncookies=1;
   sysctl -w  net.ipv4.tcp_tw_reuse=1;
   sysctl -w  net.ipv4.tcp_tw_recycle=1;
   ulimit -n 8192;

 # if service error , roll-back sysctl
 ############################################
 # sysctl -p /var/log/sysctl.bak.xxxxxxx    #
 ############################################